<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{/common/header::header-head}">
</head>
<body>
<div th:replace="~{/common/header::header-body}"></div>

<div class="container mt-3 text-justify-center">

    <table class="table table-striped">
        <thead>
        <tr>
            <th>评论标题</th>
            <th>创建时间</th>
            <th>作者</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="comment:${comments}">
            <td th:text="${comment.content}">1</td>
            <td th:text="${#dates.format(comment.getDate())}">2</td>
            <td th:text="${comment.author}">3</td>
            <td>
                <button type="button" class="btn btn-danger" th:onclick="deleteComment([[${comment.getId()}]])">删除</button>
            </td>
        </tr>
        </tbody>
    </table>

</div>
</body>
<script>
    function deleteComment(id){
        if (confirm("确认删除？")){
            location.replace(location.protocol+"//"+location.host+"/back/comment/delete/"+id);
        }
    }

    var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
    var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
        return new bootstrap.Popover(popoverTriggerEl)
    })
</script>
</html>